<!DOCTYPE html>
<html>

	<head>
		<script src="../AngularJS/angular-1.5.0/angular.min.js"></script>
		<meta charset="UTF-8">
		<title></title>
	</head>
 
	<body>

	module.directive("layout",['$http','$compile',function($http,$compile){
		return {
			restrict:"A",
			link:function($scope,element,attr){
				//监控layout一旦变化，则刷新下方布局控件
				$scope.$watch('layoutId',function(newValue,oldValue,scope){
					$http({
						method:'post',
						url:'${context}/area/getlayoutHTML',
						data:{'layoutId':newValue}
					}).success(function(data, status, headers, config){
						if(newValue!=oldValue && "undefined" != typeof(oldValue)){
							$scope.widget=[];
						}
						console.log(JSON.stringify(data))
						//更新布局ID
						if(data.html==null)return ;
						element.html("");
						html=($compile(data.html))($scope); 
						element.append(html);
						//重置RWidget
						$scope.RWidget={};
					});
				})
			}
		}
	}])
	</body>

</html>